<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Comet0.0.2测试</title>
		
        <script type="text/javascript" src="/lib/JS/JS.js">
        </script>
        <script type="text/javascript" src="/lib/JS/Observable.js">
        </script>
        <script type="text/javascript" src="/lib/JS/XMLHttpRequest.js">
        </script>
        <script type="text/javascript" src="/lib/JS/StreamingConnector.js">
        </script>
        <script type="text/javascript" src="/lib/JS/AJAX.js">
        </script>
		
		<script type="text/javascript" src="/lib/JS/EventEngine.js">
        </script>

        <script type="text/javascript">
        	var serverUrl = '/conn';
        	var connector;
        	function init(){
        		connector = new JS.StreamingConnector({
    				url :serverUrl,
    			});
        		connector.on({
    				start : function(url){
    					//log('start at:'+url);
    				},
    				stop : function(){
    					//log('stop');
    				},
    				data : function(responseText){
    					//log('event:'+responseText);
    				}
    			});
    			connector._xhr.on({
    				readyStateChange : function(readyState,status,xhr){
    					log("readyState:"+readyState+",status:"+status);
    					log(xhr.responseText);
    				}
    			});
            }
			
			function log(str){
				var d = document.getElementById('log');
				d.innerHTML += str+'<br/>';
				try{
					d.scroll(0,d.scrollHeigh);
				}catch(e){}
			}
			
			
			function conn(){
				connector.start();
			}
			function stop(){
				connector.stop();
			}
			function send(){
				
			}
			
            //JS.EventEngine.start(serverUrl + '?action=conn');
        </script>
    </head>
    <body onload="init()">
    
    <table style="width: 100%">
		<tr>
			<td style="width:50%;">聊天区</td>
			<td>用户列表</td>
		</tr>
		<tr>
			<td style="">
			
				<textarea readonly="" name="TextArea1" style="width: 100%; height: 150px" rows="1"></textarea>
			</td>
			<td style="vertical-align:top">
				<select id="userList_Dom" style="width:100%;height:150px;" multiple="multiple"></select>
			</td>
		</tr>
		<tr>
			<td style="" colspan="2">
			
				<input name="Text1" type="text" style="width: 50%; height: 22px;" />
				<input name="Reset1" type="button" onclick="send();" value="发送信息" />
				<input name="Reset2" type="button" onclick="conn();" value="连接" />
				<input name="Reset3" type="button" onclick="stop();" value="断开" />
			</td>
		</tr>
		<tr>
			<td colspan="2">
				控制台:<br />
				<div id="log" style="width:100%;height:150px;overflow:auto;border:1px navy solid;"></div>
			</td>
		</tr>
	</table>
    
    </body>
</html>
